<?php
	include_once("adb.php");
	
	class health_promo_class extends adb{
		function health_promo_class(){
			adb::adb();
		}
		/**
		*query all vaccines in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_health_promo(){
			$query="select * from health_promotion";
			
			return $this->query($query);
		}
		function get_promo($id){
			$query="select * from health_promotion where idhealth_promotion='$id'";
			
			return $this->query($query);
		}
		
		function add_health_promo($date,$venue,$topic,$method,$target_audience,$number_of_audience,$remarks,$month,$latitude,$longitude,$image,$idcho,$subdistrict_id){
			//write the SQL query and call $this->query()
			$query="insert into health_promotion (`date`, `venue`, `topic`, `method`, `target_audience`, `number_of_audience`, 
			`remarks`, `month`, `latitude`, `longitude`, `image`, `idcho`, `subdistrict_id`) values ('$date', '$venue', '$topic', '$method', 
			'$target_audience', '$number_of_audience', '$remarks', '$month', '$latitude', '$longitude', '$image', '$idcho', '$subdistrict_id')";
			return $this->query($query);
		}
		/**
		*updates the record identified by id 
		*/
		function update_health_promo($idhealth_promotion, $date,$venue,$topic,$method,$target_audience,$number_of_audience,$remarks,$month,$latitude,$longitude,$image,$idcho,$subdistrict_id){
			//write the SQL query and call $this->query()
			$query =("update health_promotion set date='$date',venue='$venue',topic='$topic',method='$method',target_audience='$target_audience',
			number_of_audience='$number_of_audience',remarks='$remarks',month='$month',latitude='$latitude',longitude='$longitude',image='$image',
			idcho='$idcho',subdistrict_id='$subdistrict_id' where idhealth_promotion='$idhealth_promotion'");
			return $this->query($query);
		}
		
		function delete_health_promo($id){
			//write the SQL query and call $this->query()
			$query= ("delete from health_promotion where idhealth_promotion = $id");
			return $this->query($query);
		}
		
		function search_health_promo($topic){
		//$query = mysql_query("select * from health promotion where venue Like '%".$venue."%'");
		$query="select * from health_promotion where topic Like '%".$topic."%'";
		return $this->query($query);
		
	}
}
?>
